package com.jic.member.controller.manage;

import com.jic.common.base.vo.RestResult;
import com.jic.member.request.TestSendMessageRequest;
import com.jic.member.request.TripBranchNodeEntityRequest;
import com.jic.member.request.TripBranchNodeIdAndTemplateCodeRequest;
import com.jic.member.request.TripBranchNodeIdRequest;
import com.jic.member.response.MessageResponse;
import com.jic.member.response.TripBranchNodeDetailResponse;
import com.jic.member.service.MessageService;
import com.jic.member.service.TripBranchNodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 分支节点
 * @author wwb
 */
@Slf4j
@Api(tags = "分支节点")
@RestController
@RequestMapping("/tripBranchNode")
public class TripBranchNodeController {

    @Resource
    private TripBranchNodeService tripBranchNodeService;

    @Resource
    private MessageService messageService;

    @ApiOperation("新增/编辑分支节点")
    @ResponseBody
    @PostMapping("/updateBranchNode")
    public RestResult<Long> updateBranchNode(@RequestBody TripBranchNodeEntityRequest tripBranchNodeEntity){
        return tripBranchNodeService.updateBranchNode(tripBranchNodeEntity);
    }

    @ApiOperation("删除分支节点")
    @ResponseBody
    @PostMapping("/delBranchNode")
    public RestResult<Boolean> delBranchNode(@RequestBody TripBranchNodeIdAndTemplateCodeRequest tripBranchNodeIdRequest){
        return tripBranchNodeService.delBranchNode(tripBranchNodeIdRequest);
    }

    @ApiOperation("查询分支节点信息")
    @ResponseBody
    @PostMapping("/getBranchNodeDetail")
    public RestResult<TripBranchNodeDetailResponse> getBranchNodeDetail(@RequestBody TripBranchNodeIdRequest tripBranchNodeIdRequest){
        return tripBranchNodeService.getBranchNodeDetail(tripBranchNodeIdRequest);
    }

    @ApiOperation("分支节点测试发送短信、邮件")
    @ResponseBody
    @PostMapping("/sendTestMessage")
    public RestResult<MessageResponse> sendTestMessage(@RequestBody TestSendMessageRequest testSendMessageRequest){
        return RestResult.success(messageService.sendTestMessage(testSendMessageRequest));
    }

}
